/*
 * @Author: 0x9DEFA478
 * @Date: 2021-11-16 00:19:06
 * @LastEditTime: 2021-11-19 01:17:06
 * @LastEditors: 0x9DEFA478
 * @Description: 
 * QQ:2652450237
 * ============================================================================================================================================
 * 
 * 
 * 
 *                                                                                               ************      ****************************
 *                                                                                             ************      ****************************  
 *                                                                                           ************      ****************************    
 *                                                                                         ************      ****************************      
 *                                                                                       ************      ************                        
 *                                                                                     ************      ************                          
 *                                                                                   ************      ************                            
 *                                                                                 ************      ************                              
 *                                                                               ************      ************                                
 *                                                                             ************      ************                                  
 *                                                                           ************      ************                                    
 *                                                                         ************      ************                                      
 *                                                                       ************      ************                                        
 *                                                                     ************      ************                                          
 *                                                                   ************      ************                                            
 *                                                                 ************      ************                                              
 *                                                               ************      ************                                                
 *                                                             ************      ************                                                  
 *                                                           ************      ************                                                    
 *                                                         ************      ************                                                      
 *                                                       ************      ************                                                        
 *                                                     ************      ************                                                          
 *                                                   ************      ************                                                            
 *                                                 ************      ************                                                              
 *                                               ************      ************                                                                
 *                                             ************      ************                                                                  
 *                                           ************      ************                                                                    
 *                                         ************      ************                                                                      
 *                                       ************      ************                                                                        
 *                                     ************      ************                                                                          
 *                                   ************      ************                                                                            
 *                                 ************      ************                                                                              
 *                               ************      ************                                                                                
 *                             ************      ************                                                                                  
 *                           ************      ************                                                                                    
 *                         ************      ************                                                                                      
 *       ****************************      ************                                                                                        
 *     ****************************      ************                                                                                          
 *   ****************************      ************                                                                                            
 * ****************************      ************                                                                                              
 * 
 * 
 * 
 * ============================================================================================================================================
 * 
 */
#include "./H_FIFO_Builder.h"

/**
 * @brief 创建H_FIFO
 * @param Type 等同于H_FIFO_Init()参数中的Type
 * @param BufferSize 等同于H_FIFO_Init()参数中的BufferSize
 * @return NULL:失败 其他:成功
 */
H_FIFO* new_H_FIFO(int Type,int BufferSize,H_MemoryMalloc* memoryMalloc){

  H_FIFO* fifo;
  void* Buffer;
  Huint32 i;

  switch(Type){
    case vH_FIFO_Type_byte:
      i=BufferSize;
      break;
    case vH_FIFO_Type_uint16:
      i=BufferSize*2;
      break;
    case vH_FIFO_Type_uint32:
      i=BufferSize*4;
      break;
    case vH_FIFO_Type_uint64:
      i=BufferSize*8;
      break;
    default:
      fifo=NULL;
      break;
  }

  fifo=H_MemoryMalloc_ArrayMalloc(memoryMalloc,sizeof(H_FIFO),&Buffer,&i,1);
  if(fifo==NULL){
    return NULL;
  }

  H_FIFO_Init(fifo,Type,Buffer,BufferSize);

  return fifo;
}

/**
 * @brief 释放H_FIFO
 * @param fifo 要释放的H_FIFO
 * @return 无
 */
void delete_H_FIFO(H_FIFO* fifo){

  H_MemoryMalloc_ArrayFree(fifo,sizeof(H_FIFO));
}

